laravel 的樣板功能有提供好用的繼承的方式,可以讓你重複使用樣板,讓程式可重複性提高。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{ Config::get('app.name') }} - @section('title')
@show</title>
@include('base.header')
</head>
<body>
@include('base.top_bar')
@include('base.left_bar')
@section('content')
@show
@include('base.footer')
@include('base.core_js')
<script type="text/javascript">
@section('my_script')
@show
</script>
</body>
</html>
@extends('base')
@section('title')
Create Page
@stop
@section('my_script')
{{-- <script type="text/javascript" > --}}
function() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$("btn_say_hi").click(function(){
alert( " hi " );
});
}()
{{-- </script> --}}
@stop
@section('content')
<!-- cxpage start 頁面內容 start -->
<!-- Panel -->
<div class="panel">
<div class="panel-body container-fluid">
<div class="row row-lg">
<div class="col-md-12 col-xs-12">
<div class="wrap">
<h3 class="title">用戶管理</h3>
<div class="table-responsive">
<table id="table_list_userdomain" class="table table-striped table-bordered">
<thead>
<tr>
<th>#</th>
<th style="display: none;"></th>
<th>帳號</th>
<th>備註</th>
</tr>
</thead>
<tbody>
@foreach ($TPL['adata'] as $doman )
<tr>
<td>
{{ $loop->index+1+ ( ((int)$TPL['dbData']->currentPage() - 1 ) * (int)$TPL['dbData']->perPage() ) }}
</td>
<td style="display: none;">{{ $doman['id'] }}</td>
<td>{{ $doman['user_name'] }}</td>
<td>{{ $doman['momo'] }}</td>
</tr>
@endforeach
</tbody>
</table>
{{ $TPL['dbData']->links('pagination.default') }}
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Panel END -->
</div>
</div>
<!-- End Page -->
@stop
小弟使用覺得 blade 樣板系統 和codeigniter 以及 很久以前的Smarty 比起來,其實都差不多,但多了可以extends 和 incloud 以及簡單的 if 和 foreach ,實際上用起來蠻方便的。